package com.wla.advice;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: lijinze
 * @createDate: 2020/7/28
 */
@ControllerAdvice
public class MyControllerAdvice {

    @ModelAttribute(name = "text")
    public Map<String, Object> getMyData() {
        Map<String, Object> map = new HashMap<>();
        map.put("name", "chairs li");
        return map;
    }

    @InitBinder("b")
    public void b(WebDataBinder binder) {
        binder.setFieldDefaultPrefix("b.");
    }
    @InitBinder("a")
    public void a(WebDataBinder binder) {
        binder.setFieldDefaultPrefix("a.");
    }
}
